package com.dongdongshop.config;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliSmsClientConfig {

    @Value("${config.endpoint}")
    private String endpoint;
    @Value("${config.accessKeyId}")
    private String accessKeyId;
    @Value("${config.accessKeySecret}")
    private String accessKeySecret;

    @Bean
    public Client client(){
        Client client =null;
        try {
            Config config = new Config()
                    // 您的 AccessKey ID
                    .setAccessKeyId(accessKeyId)
                    // 您的 AccessKey Secret
                    .setAccessKeySecret(accessKeySecret);
            // 访问的域名
            config.endpoint = endpoint;
             client = new Client(config);
            System.out.println("阿里大于配置类加载成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return client;
    }
}
